# -*- conding:UTF-8 -*-

'''
@ Project: shop
@ File: serializer.py
@ Author: 韩成瑾
@ Date：2022/4/28 13:59

'''
from rest_framework.serializers import ModelSerializer
from users.models import Users

from goods.models import Category,Carousel,Goods,GoodImg,GoodLike

# 轮播图
class CarouselSer(ModelSerializer):
    class Meta:
        model = Carousel
        fields = '__all__'

# 全部商品
class GoodsSer(ModelSerializer):
    class Meta:
        model = Goods
        fields = '__all__'

# 定义商品详情的序列化器
class GoodImgSer(ModelSerializer):
    class Meta:
        model = GoodImg
        fields = '__all__'

# 定义用户的序列化器
class UserSer(ModelSerializer):
    class Meta:
        model = Users
        fields = "__all__"

# 收藏商品
class GoodLikeSer(ModelSerializer):
    user = UserSer(read_only=True)
    goods = GoodsSer(read_only=True)
    class Meta:
        model = GoodLike
        fields = "__all__"

class CategorySer(ModelSerializer):
    class Meta:
        model = Category
        field = '__all__'